package com.app.shop.adapters;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.app.shop.R;
import com.app.shop.beans.TalkBean;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;


public class  TalkAdapter extends BaseQuickAdapter<TalkBean, TalkAdapter.ViewHolder> {


    int from;

    public TalkAdapter(int layout, @Nullable List<TalkBean> data) {
        super(layout, data);
    }

    public TalkAdapter(int layout, @Nullable List<TalkBean> data, int from) {
        super(layout, data);
        this.from = from;
    }


    @Override
    protected void convert(ViewHolder holder, TalkBean bean) {
        holder.tv_name.setText(bean.getUser());
        holder.tv_time.setText(bean.getCreate_time());
        holder.tv_content.setText(bean.getContent());
        holder.tv_del_item.setVisibility(from == 1 ? View.VISIBLE : View.GONE);
        holder.addOnClickListener(R.id.tv_del_item);


    }


    public class ViewHolder extends BaseViewHolder {
        TextView tv_name;
        TextView tv_time;
        TextView tv_content;
        TextView tv_del_item;


        public ViewHolder(View view) {
            super(view);
            tv_name = view.findViewById(R.id.tv_username);
            tv_time = view.findViewById(R.id.tv_time);
            tv_content = view.findViewById(R.id.tv_content);
            tv_del_item = view.findViewById(R.id.tv_del_item);
        }
    }
}
